/**
 *       Copyright (c) 2012 Lukas Zaruba
 *
 *   This file is part of Robot Playground.
 *
 *   Robot Playground is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU Lesser General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   Robot Playground is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU Lesser General Public License for more details.
 *
 *   You should have received a copy of the GNU Lesser General Public License
 *   along with Robot Playground. If not, see <http://www.gnu.org/licenses/>.
 */
package net.zarubsys.robotplayground.core.functions;

import java.util.Collections;
import java.util.List;

/**
 * IFunction
 *
 * @author Lukas Zaruba, lukas.zaruba@gmail.com
 */
public class FunctionDescriptor {
	
	private final String name;
	private final List<Parameter> parameters;
	private final Parameter returnParameter;
	private final String description;
	
	public FunctionDescriptor(String name, List<Parameter> parameters, Parameter returnParameter, String description) {
		if (name == null) throw new IllegalArgumentException("name cannot be null");
		if (parameters == null) throw new IllegalArgumentException("parameters cannot be null, if there are no parameters pass empty list");
		
		this.name = name;
		this.parameters = Collections.unmodifiableList(parameters);
		this.returnParameter = returnParameter;
		this.description = description;
	}
	
	public List<Parameter> getParameters() {
		return parameters;
	}
	
	public Parameter getReturnParameter() {
		return returnParameter;
	}
	
	public String getName() {
		return name;
	}
	
	public String getDescription() {
		return description;
	}

	@Override
	public boolean equals(Object obj) {
		if (!(obj instanceof FunctionDescriptor)) return false;
		return name.equals(((FunctionDescriptor) obj).name);
	}

	@Override
	public int hashCode() {
		return name.hashCode();
	}
	
}

